<template>
  <div class="pages" v-if="signalsRadio1.total > 10">
    <el-pagination v-model:current-page="signalsRadio1.page.currentPage" v-model:page-size="signalsRadio1.page.pageSize"
      :page-sizes="[10, 15, 20, 25]" :small="small" :disabled="disabled" :background="background"
      layout="sizes, prev, pager, next" :total="signalsRadio1.total ? signalsRadio1.total : 100"
      @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  </div>
</template>

<script setup>
import { reactive, ref } from "vue";
import { useRadio1Store } from "@/pain/search/search";
import { useCounterVip } from "@/pain/vip/index.js";
import { useCounterStore } from "@/pain/login/login.js";
import { decrypt } from "@/utils/index";
import { useRouter } from "vue-router";
import { userInfo } from "@/Api/api.js"
const router = useRouter();
const useVip = useCounterVip();
const usdl = useCounterStore();
const signalsRadio1 = useRadio1Store();
const currentPage = ref(1);
const pageSize = ref(10);
const tokens = localStorage.getItem("token");
let token
if (tokens) {
  userInfo().then(rex => {
    token = rex.data.data
  })
}
const handleSizeChange = (val) => {
  if (!tokens) {
    pageSize.value = 10
    signalsRadio1.page.pageSize = 10
    usdl.uselogin = true;
    return;
  }
  if (val > 10 && token.level_id < 2) {
    return (useVip.maskShow = true);
  }
  pageSize.value = val;
  signalsRadio1.page.pageSize = val;
  if (signalsRadio1.id == "1") {
    signalsRadio1.getsearchs();
  } else if (signalsRadio1.id == "2") {
    signalsRadio1.getsuppliers();
  } else if (signalsRadio1.id == "3") {
    signalsRadio1.getbuyers();
  } else if (signalsRadio1.id == "5") {
    signalsRadio1.getforecasts();
  } else if (signalsRadio1.id == "7") {
    signalsRadio1.getenderings();
  } else if (signalsRadio1.id == "8") {
    signalsRadio1.getcompanys();
  } else if (signalsRadio1.id == "6") {
    signalsRadio1.getprojects();
  } else if (signalsRadio1.id == "4") {
    signalsRadio1.getbrands();
  }
};

const handleCurrentChange = (val) => {
  if (!tokens) {
    currentPage.value = 1
    signalsRadio1.page.currentPage = 1
    usdl.uselogin = true;
    return;
  }
  currentPage.value = val;
  signalsRadio1.page.currentPage = val;
  if (signalsRadio1.id == "1") {
    signalsRadio1.getsearchs();
    console.log("111");
  } else if (signalsRadio1.id == "2") {
    console.log("222");
    signalsRadio1.getsuppliers();
  } else if (signalsRadio1.id == "3") {
    signalsRadio1.getbuyers();
  } else if (signalsRadio1.id == "7") {
    signalsRadio1.getenderings();
  } else if (signalsRadio1.id == "8") {
    signalsRadio1.getcompanys();
  } else if (signalsRadio1.id == "6") {
    signalsRadio1.getprojects();
  } else if (signalsRadio1.id == "4") {
    signalsRadio1.getbrands();
  } else if (signalsRadio1.id == "5") {
    signalsRadio1.getforecasts();
  }
};

// defineExpose({ currentPage , pageSize })
</script>

<style lang="scss" scoped>
.pages {
  padding: 20px;
}
</style>
